package com.one.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.one.bean.Management;
import com.one.bean.Product;
import com.one.mapper.BuyingGoodsMapper;
import com.one.mapper.ManagementMapper;
import com.one.service.RushToPurchaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
  * @author : zzh
  * @date : 2022/1/16
  * @return :
  * @description : 抢购商品活动实现类
 */
@Service
public class RushToPurchase implements RushToPurchaseService {

    @Autowired
    private BuyingGoodsMapper buyingGoodsMapper;

    @Autowired
    private ManagementMapper managementMapper;

    @Override
    public List<Product> selectBuyGoods() {
        LambdaQueryWrapper<Product> wrapper = new LambdaQueryWrapper<>();
        LambdaQueryWrapper<Product> eq = wrapper.eq(Product::getPurchase, 1);
        return buyingGoodsMapper.selectList(wrapper);

    }

    @Override
    public Integer addManagement(Management management) {
        return managementMapper.insert(management);
    }

    @Override
    public List<Management> selectAllManagement() {
        LambdaQueryWrapper<Management> wrapper = new LambdaQueryWrapper<>();
        return managementMapper.selectList(wrapper);
    }
}
